#include "data.h"

//default constructor:
data::data( ){

		int i,j;
		for ( i = 0; i < _nbJobs; i++) 
			_jobs.push_back(i);
		
		for ( i = 0; i < _nbStages; i++) {
			_stages.push_back(i);
			for ( j = 0; j < _nbMachinesPerStage; j++)
				_machines.push_back( i * _nbMachinesPerStage + j );
		}

		for ( i = 0; i <_nbJobs; i ++) 
			for ( j = 0; j < _nbStages; j++)
				_ptimes.push_back( i * _nbStages +j);

	}


data::data( int nbJobs, int nbStages, int nbMachinesPerStage){
		_nbJobs = nbJobs;
		_nbStages = nbStages;
		_nbMachinesPerStage = nbMachinesPerStage;
		int i,j;
		for ( i = 0; i < _nbJobs; i++) 
			_jobs.push_back(i);
		
		for ( i = 0; i < _nbStages; i++) {
			_stages.push_back(i);
			for ( j = 0; j < _nbMachinesPerStage; j++)
				_machines.push_back( i * _nbMachinesPerStage + j );
		}

		for ( i = 0; i <_nbJobs; i ++) 
			for ( j = 0; j < _nbStages; j++)
				_ptimes.push_back( i * _nbStages +j);

	}

int data::getnbJobs() {
		return _nbJobs;
	}
	
int data::getnbStages() {
		return _nbStages;
	}

int data::getJobs(int i) {
		return _jobs[i];
	}

void data::setJobs( int i, int j) {
		_jobs[i] = j;
	}

void data::deleteJobs(int i) {
		deque<int>::iterator it = _jobs.begin();
		_jobs.erase(it +i );
		_nbJobs --;
		
    	it = _ptimes.begin();
		_ptimes.erase( it + i * _nbStages, it + (i + 1) * _nbStages );
 
	}


void data::setStimes( int i, int j, int k) {	
		_stimes[i * _nbStages +j ] = k;
	}

int data::getStimes( int i, int j) {	
		return _stimes[i * _nbStages +j ];
	}

void data::setPtimes( int i, int j, int k) {	
		_ptimes[i * _nbStages +j ] = k;
	}

int data::getPtimes( int i, int j) {	
		return _ptimes[i * _nbStages +j ];
	}

void data::setEtimes( int i, int j) {	
		_etimes[i * _nbStages +j ] =   _stimes[i * _nbStages +j ]
			                         + _ptimes[i * _nbStages +j ];
	}

int data::getEtimes( int i, int j) {	
		return _etimes[i * _nbStages +j ];
	}


void data::setMachines( int i, int j, int k ) {
		_machines[ i * _nbMachinesPerStage +j ] = k;
	}

int data::getMachines( int i, int j) {
		return _machines [ i * _nbMachinesPerStage +j  ];
	}

void data::setnbMachinesPerStage(int k) {
		_nbMachinesPerStage = k;
	}

int data::getnbMachinesPerStage() {
		return _nbMachinesPerStage;
	}

